Skip to content

numfmt: reject %f values too large to format exactly#12012

Merged
cakebaker merged 1 commit intouutils:mainfrom
pocopepe:11936
May 1, 2026
Merged

numfmt: reject %f values too large to format exactly#12012
cakebaker merged 1 commit intouutils:mainfrom
pocopepe:11936

Conversation

@pocopepe
Copy link
Copy Markdown
Contributor

Fixes #11936

%N.Mf was silently lossy for very large ints via the f64 path. Now bails out when the value would need 20+ digits to print, like GNU does.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 26, 2026

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/retry is no longer failing!
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.

Comment thread src/uu/numfmt/src/format.rs Outdated
Comment thread src/uu/numfmt/src/format.rs Outdated
let scaled = integer / to_unit;

Some(if precision == 0 {
// reject when formatted output would need 20+ digits
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please move this check into a new function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, extracted into is_too_large_to_format

@cakebaker cakebaker merged commit 375fc3c into uutils:main May 1, 2026
169 checks passed
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

numfmt: --format=%N.Mf silently prints lossy output for very large integers (GNU rejects)

3 participants